package com.baiqian.doupo.command;

import com.baiqian.doupo.Utils;
import com.baiqian.doupo.capability.DouPoModCapability;
import com.baiqian.doupo.capability.douqi.IDouQiCapability;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.command.CommandSource;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.common.util.LazyOptional;

public class ReBirthCommand implements Command<CommandSource> {
        public static ReBirthCommand instance = new ReBirthCommand();

        @Override
        public int run(CommandContext<CommandSource> context) {
            LazyOptional<IDouQiCapability> douQiCap = context.getSource().getEntity().getCapability(DouPoModCapability.DOUQI_CAPABILTTY);
            if(douQiCap.isPresent()){
                douQiCap.ifPresent((l) -> {
                    l.rebirth();
                });
            }
            context.getSource().sendFeedback(new TranslationTextComponent("cmd." + Utils.MOD_ID + ".rebirth"), false);
            return 0;
        }
    }
